/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techopropio.bfh.service;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import com.techopropio.bfh.dao.Conexion;
import com.techopropio.bfh.model.Convocatoria;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Home
 */
public class ConvocatoriaDAOImpl implements ConvocatoriaDAO{
    Convocatoria convocatoria=null;
    
    @Override
    public Convocatoria findActiva() {
        try {
            Connection conn = Conexion.obtenerConnexion();
                
            Statement st = (Statement) conn.createStatement();
            ResultSet rs = st.executeQuery("select * from convocatoria where estado='Activo'");
            
            if(rs.next()){
                convocatoria = new Convocatoria();
                convocatoria.setFechaFin(rs.getDate("fechaTermino"));
                convocatoria.setFechaIncio(rs.getDate("fechaInicio"));
                convocatoria.setNombre(rs.getString("nombreConvocatoria"));
                convocatoria.setId(rs.getInt("idConvocatoria"));
                convocatoria.setNroBonos(rs.getInt("totalBonos"));
            }
            
        } catch (SQLException ex) {
            Logger.getLogger(ConvocatoriaDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return convocatoria;
        
    }

    
    
}
